const Koa = require('koa')
const bodyParser = require('koa-bodyparser')

const errorHandler = require('./error-handler')

// const userRouter = require('../routers/user.router')
// const authRouter = require('../routers/auth.router')
// 手动导入路由的写法改由 useRoutes 文件统一管理：
const useRoutes = require('../routers')

const app = new Koa()


app.use(bodyParser())
// app.use(userRouter.routes())
// app.use(authRouter.routes())
useRoutes.call(app)


// 监控全局的错误处理
app.on('error', errorHandler)


module.exports = app